define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'user_score/index' + location.search,
                    del_url: 'user_score/del',
                    table: 'score',
                }
            });

            var table = $("#table");
            table.on('load-success.bs.table', function (e, data) {
                //这里可以获取从服务端获取的JSON数据
                console.log(data);
                $('#score').html(data.data.score)

            });
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {field: 'id', title: __('Id')},
                        {field: 'staff_id', title: __('Staff id')},
                        {field: 'staff.mobile', title: __('Staff mobile')},
                        {field: 'user_id', title: __('User id')},
                        {field: 'user.mobile', title: __('User mobile')},
                        {field: 'score', title: __('Score'), operate: false},
                        {field: 'before', title: __('Before'), operate: false},
                        {field: 'after', title: __('After'), operate: false},
                        {field: 'memo', title: __('Memo'), operate: false},
                        {field: 'status', title: __('Status'),
                            searchList: Config.statusList,
                            formatter: Table.api.formatter.status
                        },
                        {
                            field: 'createtime',
                            title: __('Create time'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            autocomplete: false,
                            formatter: Table.api.formatter.datetime
                        },
                        {
                            field: 'cancel',
                            title: __('Cancel'),
                            searchList: {100:"No",200:"Yes"},
                            formatter: Table.api.formatter.status
                        },
                        {
                            field: 'cancel_time',
                            title: __('Cancel time'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            autocomplete: false,
                            formatter: Table.api.formatter.datetime
                        },
                        {
                            field: 'log_id',
                            title: __('Cancel log id'),operate: false
                        },
                        // {field: 'shop_id', title: __('Shop_id')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
